package cn.admin.controller;

import cn.admin.config.key.StatusCode;
import cn.admin.service.InvitationCodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: 毛苏宇
 * @Description: You can do it!
 * @Date: Create in 16:12 2019/4/20
 */
@RestController
@RequestMapping("/invitation_code")
public class InvitationCodeController {

    @Autowired
    private InvitationCodeService invitationCodeService;

    @PostMapping("/modify")
    public String updateCode(@RequestParam("code")String code){
        //邀请码的长度必须为3
        if (code.length()==3){
            boolean b = invitationCodeService.modifyCode(code);
            if (b){
                return StatusCode.STATUS_SUCCESS;
            }else {
                return StatusCode.STATUS_FAIL;
            }
        }else{
            return StatusCode.STATUS_LENGTH_RESTRICTION;
        }
    }

}
